home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Special 21 / AMIGAplus Sonderheft 21 (1999)(ICP)(DE)[!].iso / PublicDomain / Spiele / scott / source / Source.lha / SCOTT.c < prev    next >
C/C++ Source or Header  |  1999-04-04  |  18KB  |  895 lines

  1. #include "SCOTT_A.c"
  2.  
  3. void choice(void)
  4. {
  5.     BYTE key;
  6.  
  7.     put_choice();
  8.     while (1) {
  9.         key = KeyInput();
  10.         //printf("Key: %c\n",key);
  11.         if (tolower(key) == 'e') {
  12.             close_all();
  13.             exit(0);
  14.         }
  15.         if (tolower(key) == 'r') {
  16.             cursor(FALSE);
  17.             WriteCON("Restore\n");
  18.             Speak("Restore");
  19.             OutReset();
  20.             if (RestoreGame() == FALSE) {
  21.                 Look();
  22.                 break;
  23.             }
  24.             else put_choice();
  25.         }
  26.         if ((tolower(key) == 's') && RESTART) {
  27.             cursor(FALSE);
  28.             WriteCON("Restart\n");
  29.             Speak("Restart");
  30.             OutReset();
  31.             if ((LoadRestart() == FALSE) && RESTART) {
  32.                 Restart();
  33.                 break;
  34.             }
  35.             else put_choice();
  36.         }
  37.     }
  38. }
  39.  
  40. void SaveBody(FILE *f)
  41. {
  42.     int ct;
  43.  
  44.     for(ct=0;ct<16;ct++)
  45.     {
  46.         fprintf(f,"%d %d\n",Counters[ct],RoomSaved[ct]);
  47.     }
  48.     fprintf(f,"%ld %d %hd %d %d %hd\n",BitFlags, (BitFlags&(1L<<DARKBIT))?1:0,
  49.         MyLoc,CurrentCounter,SavedRoom,GameHeader.LightTime);
  50.     for(ct=0;ct<=GameHeader.NumItems;ct++)
  51.         fprintf(f,"%hd\n",(short)Items[ct].Location);
  52.     fclose(f);
  53. }
  54.  
  55. void LoadBody(FILE *f)
  56. {
  57.     int ct;
  58.     short lo;
  59.     short DarkFlag;
  60.  
  61.     for(ct=0;ct<16;ct++)
  62.     {
  63.         fscanf(f,"%d %d\n",&Counters[ct],&RoomSaved[ct]);
  64.     }
  65.     fscanf(f,"%ld %d %hd %d %d %hd\n",
  66.         &BitFlags,&DarkFlag,&MyLoc,&CurrentCounter,&SavedRoom,
  67.         &GameHeader.LightTime);
  68.     /* Backward compatibility */
  69.     if(DarkFlag)
  70.         BitFlags|=(1L<<15);
  71.     for(ct=0;ct<=GameHeader.NumItems;ct++)
  72.     {
  73.         fscanf(f,"%hd\n",&lo);
  74.         Items[ct].Location=(unsigned char)lo;
  75.     }
  76.     fclose(f);
  77. }
  78.  
  79. BOOL SaveRestart()
  80. {
  81.     FILE *f;
  82.  
  83.     f = fopen(restart_file,"w");
  84.     if (f==NULL) return(TRUE);
  85.     SaveBody(f);
  86.     //SetProtection(restart_file,128);
  87.     restart_lock = Lock(restart_file,SHARED_LOCK);
  88.     return(FALSE);
  89. }
  90.  
  91. BOOL LoadRestart()
  92. {
  93.     FILE *f=
  94.  
  95.     f = fopen(restart_file,"r");
  96.     if (f==NULL) return(TRUE);
  97.     LoadBody(f);
  98.     return(FALSE);
  99. }
  100.  
  101. int PerformLine(int ct)
  102. {
  103.     int continuation=0;
  104.     int param[5],pptr=0;
  105.     int act[4];
  106.     int cc=0;
  107.  
  108.     while(cc<5)
  109.     {
  110.         int cv,dv;
  111.         cv=Actions[ct].Condition[cc];
  112.         dv=cv/20;
  113.         cv=cv%20;
  114.         //cv%=20;
  115.         switch(cv)
  116.         {
  117.             case 0:
  118.                 param[pptr++]=dv;
  119.                 break;
  120.             case 1:
  121.                 if(Items[dv].Location!=CARRIED)
  122.                     return(0);
  123.                 break;
  124.             case 2:
  125.                 if(Items[dv].Location!=MyLoc)
  126.                     return(0);
  127.                 break;
  128.             case 3:
  129.                 if(Items[dv].Location!=CARRIED&&
  130.                     Items[dv].Location!=MyLoc)
  131.                     return(0);
  132.                 break;
  133.             case 4:
  134.                 if(MyLoc!=dv)
  135.                     return(0);
  136.                 break;
  137.             case 5:
  138.                 if(Items[dv].Location==MyLoc)
  139.                     return(0);
  140.                 break;
  141.             case 6:
  142.                 if(Items[dv].Location==CARRIED)
  143.                     return(0);
  144.                 break;
  145.             case 7:
  146.                 if(MyLoc==dv)
  147.                     return(0);
  148.                 break;
  149.             case 8:
  150.                 if((BitFlags&(1L<<dv))==0)
  151.                     return(0);
  152.                 break;
  153.             case 9:
  154.                 if(BitFlags&(1L<<dv))
  155.                     return(0);
  156.                 break;
  157.             case 10:
  158.                 if(CountCarried()==0)
  159.                     return(0);
  160.                 break;
  161.             case 11:
  162.                 if(CountCarried())
  163.                     return(0);
  164.                 break;
  165.             case 12:
  166.                 if(Items[dv].Location==CARRIED||Items[dv].Location==MyLoc)
  167.                     return(0);
  168.                 break;
  169.             case 13:
  170.                 if(Items[dv].Location==0)
  171.                     return(0);
  172.                 break;
  173.             case 14:
  174.                 if(Items[dv].Location)
  175.                     return(0);
  176.                 break;
  177.             case 15:
  178.                 if(CurrentCounter>dv)
  179.                     return(0);
  180.                 break;
  181.             case 16:
  182.                 if(CurrentCounter<=dv)
  183.                     return(0);
  184.                 break;
  185.             case 17:
  186.                 if(Items[dv].Location!=Items[dv].InitialLoc)
  187.                     return(0);
  188.                 break;
  189.             case 18:
  190.                 if(Items[dv].Location==Items[dv].InitialLoc)
  191.                     return(0);
  192.                 break;
  193.             case 19: /* Only seen in Brian Howarth games so far */
  194.                 if(CurrentCounter!=dv)
  195.                     return(0);
  196.                 break;
  197.         }
  198.         cc++;
  199.     }
  200.     /* Actions */
  201.     act[0]=Actions[ct].Action[0];
  202.     act[2]=Actions[ct].Action[1];
  203.     act[1]=act[0]%150;
  204.     act[3]=act[2]%150;
  205.     act[0]/=150;
  206.     act[2]/=150;
  207.     cc=0;
  208.     pptr=0;
  209.     while(cc<4)
  210.     {
  211.         //printf("Action: %d\n",act[cc]);
  212.         if(act[cc]>=1 && act[cc]<52)
  213.         {
  214.             Output(Messages[act[cc]]);
  215.             Speak(Messages[act[cc]]);
  216.             Output("\n");
  217.         }
  218.         else if(act[cc]>101)
  219.         {
  220.             Output(Messages[act[cc]-50]);
  221.             Speak(Messages[act[cc]-50]);
  222.             Output("\n");
  223.         }
  224.         else switch(act[cc])
  225.         {
  226.             case 0: /* NOP */
  227.                 break;
  228.             case 52:
  229.                 if(CountCarried()==GameHeader.MaxCarry)
  230.                 {
  231.                     if(Options&YOUARE) {
  232.                         Output("You are carrying too much.\n");
  233.                         Speak("You are carrying too much.");
  234.                     }
  235.                     else {
  236.                         Output("I've too much to carry!\n");
  237.                         Speak("I've too much to carry!");
  238.                     }
  239.                     break;
  240.                 }
  241.                 if(Items[param[pptr]].Location==MyLoc)
  242.                     Redraw=1;
  243.                 Items[param[pptr++]].Location= CARRIED;
  244.                 break;
  245.             case 53:
  246.                 Redraw=1;
  247.                 Items[param[pptr++]].Location=MyLoc;
  248.                 break;
  249.             case 54:
  250.                 Redraw=1;
  251.                 MyLoc=param[pptr++];
  252.                 break;
  253.             case 55:
  254.                 if(Items[param[pptr]].Location==MyLoc)
  255.                     Redraw=1;
  256.                 Items[param[pptr++]].Location=0;
  257.                 break;
  258.             case 56:
  259.                 BitFlags|=1L<<DARKBIT;
  260.                 break;
  261.             case 57:
  262.                 BitFlags&=~(1L<<DARKBIT);
  263.                 break;
  264.             case 58:
  265.                 BitFlags|=(1L<<param[pptr++]);
  266.                 break;
  267.             case 59:
  268.                 if(Items[param[pptr]].Location==MyLoc)
  269.                     Redraw=1;
  270.                 Items[param[pptr++]].Location=0;
  271.                 break;
  272.             case 60:
  273.                 BitFlags&=~(1L<<param[pptr++]);
  274.                 break;
  275.             case 61:
  276.                 if(Options&YOUARE) {
  277.                     Output("You are dead.\n");
  278.                     Speak("You are dead.");
  279.                 }
  280.                 else {
  281.                     Output("I am dead.\n");
  282.                     Speak("I am dead.");
  283.                 }
  284.                 BitFlags&=~(1L<<DARKBIT);
  285.                 MyLoc=GameHeader.NumRooms; /* It seems to be what the code says! */
  286.                 Look();
  287.                 break;
  288.             case 62:
  289.             {
  290.                 /* Bug fix for some systems - before it could get parameters wrong */
  291.                 int i=param[pptr++];
  292.                 Items[i].Location=param[pptr++];
  293.                 Redraw=1;
  294.                 break;
  295.             }
  296.             case 63:
  297. doneit:         OutBuf("The game is now over!\n");
  298.                 Speak("The game is now over!");
  299.                 choice();
  300.                 break;
  301.             case 64:
  302.                 Look();
  303.                 break;
  304.             case 65:
  305.             {
  306.                 int ct=0;
  307.                 int n=0;
  308.                 while(ct<=GameHeader.NumItems)
  309.                 {
  310.                     if(Items[ct].Location==GameHeader.TreasureRoom &&
  311.                       *Items[ct].Text=='*')
  312.                         n++;
  313.                     ct++;
  314.                 }
  315.                 if(Options&YOUARE) {
  316.                     Output("You have stored ");
  317.                     Speak("You have stored ");
  318.                 }
  319.                 else {
  320.                     Output("I've stored ");
  321.                     Speak("I've stored ");
  322.                 }
  323.                 OutputNumber(n);
  324.                 SpeakNum(n);
  325.                 Output("treasures.\nOn a scale of 0 to 100, that scores ");
  326.                 Speak("treasures. On a scale of 0 to hundred that scores ");
  327.                 OutputNumber((n*100)/GameHeader.Treasures);
  328.                 SpeakNum((n*100)/GameHeader.Treasures);
  329.                 Output("points.\n");
  330.                 Speak("points.");
  331.                 if(n==GameHeader.Treasures)
  332.                 {
  333.                     Output("Well done.\n");
  334.                     Speak("Well done.");
  335.                     goto doneit;
  336.                 }
  337.                 break;
  338.             }
  339.             case 66:
  340.             {
  341.                 int ct=0;
  342.                 int f=0;
  343.                 if(Options&YOUARE) {
  344.                     Output("You are carrying:\n");
  345.                     Speak("You are carrying:");
  346.                 }
  347.                 else {
  348.                     Output("I'm carrying:\n");
  349.                     Speak("I'm carrying:");
  350.                 }
  351.                 while(ct<=GameHeader.NumItems)
  352.                 {
  353.                     if(Items[ct].Location==CARRIED)
  354.                     {
  355.                         if(f==1)
  356.                         {
  357.                             if (Options & TRS80_STYLE)
  358.                                 Output(". ");
  359.                             else
  360.                                 Output(" - ");
  361.                         }
  362.                         f=1;
  363.                         Output(Items[ct].Text);
  364.                         Speak(Items[ct].Text);
  365.                     }
  366.                     ct++;
  367.                 }
  368.                 if(f==0) {
  369.                     Output("Nothing");
  370.                     Speak("Nothing");
  371.                 }
  372.                 Output(".\n");
  373.                 break;
  374.             }
  375.             case 67:
  376.                 BitFlags|=(1L<<0);
  377.                 break;
  378.             case 68:
  379.                 BitFlags&=~(1L<<0);
  380.                 break;
  381.             case 69:
  382.                 GameHeader.LightTime=LightRefill;
  383.                 if(Items[LIGHT_SOURCE].Location==MyLoc)
  384.                     Redraw=1;
  385.                 Items[LIGHT_SOURCE].Location=CARRIED;
  386.                 BitFlags&=~(1L<<LIGHTOUTBIT);
  387.                 break;
  388.             case 70:
  389.                 clrscr(); /* pdd. */
  390.                 OutReset();
  391.                 break;
  392.             case 71:
  393.                 SaveGame();
  394.                 break;
  395.             case 72:
  396.             {
  397.                 int i1=param[pptr++];
  398.                 int i2=param[pptr++];
  399.                 int t=Items[i1].Location;
  400.                 if(t==MyLoc || Items[i2].Location==MyLoc)
  401.                     Redraw=1;
  402.                 Items[i1].Location=Items[i2].Location;
  403.                 Items[i2].Location=t;
  404.                 break;
  405.             }
  406.             case 73:
  407.                 continuation=1;
  408.                 break;
  409.             case 74:
  410.                 if(Items[param[pptr]].Location==MyLoc)
  411.                     Redraw=1;
  412.                 Items[param[pptr++]].Location= CARRIED;
  413.                 break;
  414.             case 75:
  415.             {
  416.                 int i1,i2;
  417.                 i1=param[pptr++];
  418.                 i2=param[pptr++];
  419.                 if(Items[i1].Location==MyLoc)
  420.                     Redraw=1;
  421.                 Items[i1].Location=Items[i2].Location;
  422.                 if(Items[i2].Location==MyLoc)
  423.                     Redraw=1;
  424.                 break;
  425.             }
  426.             case 76:    /* Looking at adventure .. */
  427.                 Look();
  428.                 break;
  429.             case 77:
  430.                 if(CurrentCounter>=0)
  431.                     CurrentCounter--;
  432.                 break;
  433.             case 78:
  434.                 OutputNumber(CurrentCounter);
  435.                 SpeakNum(CurrentCounter);
  436.                 break;
  437.             case 79:
  438.                 CurrentCounter=param[pptr++];
  439.                 break;
  440.             case 80:
  441.             {
  442.                 int t=MyLoc;
  443.                 MyLoc=SavedRoom;
  444.                 SavedRoom=t;
  445.                 Redraw=1;
  446.                 break;
  447.             }
  448.             case 81:
  449.             {
  450.                 /* This is somewhat guessed. Claymorgue always
  451.                    seems to do select counter n, thing, select counter n,
  452.                    but uses one value that always seems to exist. Trying
  453.                    a few options I found this gave sane results on ageing */
  454.                 int t=param[pptr++];
  455.                 int c1=CurrentCounter;
  456.                 CurrentCounter=Counters[t];
  457.                 Counters[t]=c1;
  458.                 break;
  459.             }
  460.             case 82:
  461.                 CurrentCounter+=param[pptr++];
  462.                 break;
  463.             case 83:
  464.                 CurrentCounter-=param[pptr++];
  465.                 if(CurrentCounter< -1)
  466.                     CurrentCounter= -1;
  467.                 /* Note: This seems to be needed. I don't yet
  468.                    know if there is a maximum value to limit too */
  469.                 break;
  470.             case 84:
  471.                 Output(NounText);
  472.                 break;
  473.             case 85:
  474.                 Output(NounText);
  475.                 Output("\n");
  476.                 break;
  477.             case 86:
  478.                 Output("\n");
  479.                 break;
  480.             case 87:
  481.             {
  482.                 /* Changed this to swap location<->roomflag[x]
  483.                    not roomflag 0 and x */
  484.                 int p=param[pptr++];
  485.                 int sr=MyLoc;
  486.                 MyLoc=RoomSaved[p];
  487.                 RoomSaved[p]=sr;
  488.                 Redraw=1;
  489.                 break;
  490.             }
  491.             case 88:
  492.                 Delay(100); /* DOC's say 2 seconds. Spectrum times at 1.5 */
  493.                 break;
  494.             case 89:
  495.                 //printf("A89->Param: %d\n",param[pptr]);
  496.                 if (GFX) {
  497.                     if (Handle_Pic(nroom + param[pptr++])) {
  498.                         WriteCON("\n <Hit Return>\n");
  499.                         while (KeyInput() != 13) ;
  500.                         Handle_Pic(MyLoc);
  501.                     }
  502.                 }
  503.                 else pptr++;
  504.                 /* SAGA draw picture n */
  505.                 /* Spectrum Seas of Blood - start combat ? */
  506.                 /* Poking this into older spectrum games causes a crash */
  507.                 break;
  508.             default:
  509.                 fprintf(stderr,"Unknown action %d [Param begins %d %d]\n",
  510.                     act[cc],param[pptr],param[pptr+1]);
  511.                 break;
  512.         }
  513.         cc++;
  514.     }
  515.     return(1+continuation);
  516. }
  517.  
  518.  
  519. int PerformActions(int vb,int no)
  520. {
  521.     static int disable_sysfunc=0;   /* Recursion lock */
  522.     int d=BitFlags&(1L<<DARKBIT);
  523.  
  524.     int ct=0;
  525.     int fl;
  526.     int doagain=0;
  527.     if(vb==1 && no == -1 )
  528.     {
  529.         Output("Give me a direction too.\n");
  530.         Speak("Give me a direction too.");
  531.         return(0);
  532.     }
  533.     if(vb==1 && no>=1 && no<=6)
  534.     {
  535.         int nl;
  536.         if(Items[LIGHT_SOURCE].Location==MyLoc ||
  537.            Items[LIGHT_SOURCE].Location==CARRIED)
  538.             d=0;
  539.         if(d) {
  540.             Output("Dangerous to move in the dark!\n");
  541.             Speak("Dangerous to move in the dark!");
  542.         }
  543.         nl=Rooms[MyLoc].Exits[no-1];
  544.         if(nl!=0)
  545.         {
  546.             MyLoc=nl;
  547.             Output("O.K.\n");
  548.             Speak("O.K.");
  549.             Look();
  550.             return(0);
  551.         }
  552.         if(d)
  553.         {
  554.             if (Options&YOUARE) {
  555.                 Output("You fell down and broke your neck.\n");
  556.                 Speak("You fell down and broke your neck.");
  557.             }
  558.             else {
  559.                 Output("I fell down and broke my neck.\n");
  560.                 Speak("I fell down and broke my neck.");
  561.             }
  562.             choice();
  563.         }
  564.         if(Options&YOUARE) {
  565.             Output("You can't go in that direction.\n");
  566.             Speak("You can't go in that direction.");
  567.         }
  568.         else {
  569.             Output("I can't go in that direction.\n");
  570.             Speak("I can't go in that direction.");
  571.         }
  572.         return(0);
  573.     }
  574.     fl= -1;
  575.     while(ct<=GameHeader.NumActions)
  576.     {
  577.         int vv,nv;
  578.         vv=Actions[ct].Vocab;
  579.         /* Think this is now right. If a line we run has an action73
  580.            run all following lines with vocab of 0,0 */
  581.         if(vb!=0 && (doagain&&vv!=0))
  582.             break;
  583.         /* Oops.. added this minor cockup fix 1.11 */
  584.         if(vb!=0 && !doagain && fl== 0)
  585.             break;
  586.         nv=vv%150;
  587.         vv/=150;
  588.         if((vv==vb)||(doagain&&Actions[ct].Vocab==0))
  589.         {
  590.             if((vv==0 && RandomPercent(nv))||doagain||
  591.                 (vv!=0 && (nv==no||nv==0)))
  592.             {
  593.                 int f2;
  594.                 if(fl== -1)
  595.                     fl= -2;
  596.                 if((f2=PerformLine(ct))>0)
  597.                 {
  598.                     /* ahah finally figured it out ! */
  599.                     fl=0;
  600.                     if(f2==2)
  601.                         doagain=1;
  602.                     if(vb!=0 && doagain==0)
  603.                         return(0);
  604.                 }
  605.             }
  606.         }
  607.         ct++;
  608.         if(Actions[ct].Vocab!=0)
  609.             doagain=0;
  610.     }
  611.     if(fl!=0 && disable_sysfunc==0)
  612.     {
  613.         int i;
  614.         if(Items[LIGHT_SOURCE].Location==MyLoc ||
  615.            Items[LIGHT_SOURCE].Location==CARRIED)
  616.             d=0;
  617.         if(vb==10 || vb==18)
  618.         {
  619.             /* Yes they really _are_ hardcoded values */
  620.             if(vb==10)
  621.             {
  622.                 if(stricmp(NounText,"ALL")==0)
  623.                 {
  624.                     int ct=0;
  625.                     int f=0;
  626.  
  627.                     if(d) {
  628.                         Output("It is dark.\n");
  629.                         Speak("It is dark.");
  630.                         return 0;
  631.                     }
  632.                     while(ct<=GameHeader.NumItems)
  633.                     {
  634.                         if(Items[ct].Location==MyLoc && Items[ct].AutoGet!=NULL && Items[ct].AutoGet[0]!='*')
  635.                         {
  636.                             no=WhichWord(Items[ct].AutoGet,Nouns);
  637.                             disable_sysfunc=1;  /* Don't recurse into auto get ! */
  638.                             PerformActions(vb,no);  /* Recursively check each items table code */
  639.                             disable_sysfunc=0;
  640.                             if(CountCarried()==GameHeader.MaxCarry)
  641.                             {
  642.                                 if(Options&YOUARE) {
  643.                                     Output("You are carrying too much.\n");
  644.                                     Speak("You are carrying too much.");
  645.                                 }
  646.                                 else {
  647.                                     Output("I've too much to carry.\n");
  648.                                     Speak("I've too much to carry.");
  649.                                 }
  650.                                 return(0);
  651.                             }
  652.                             Items[ct].Location= CARRIED;
  653.                             Redraw=1;
  654.                             OutBuf(Items[ct].Text);
  655.                             Speak(Items[ct].Text);
  656.                             Output(": O.K.\n");
  657.                             Speak(" O.K.");
  658.                             f=1;
  659.                         }
  660.                         ct++;
  661.                     }
  662.                     if(f==0) {
  663.                         Output("Nothing taken.\n");
  664.                         Speak("Nothing taken.");
  665.                     }
  666.                     return(0);
  667.                 }
  668.                 if(no==-1)
  669.                 {
  670.                     Output("What ?\n");
  671.                     Speak("What?");
  672.                     return(0);
  673.                 }
  674.                 if(CountCarried()==GameHeader.MaxCarry)
  675.                 {
  676.                     if(Options&YOUARE) {
  677.                         Output("You are carrying too much.\n");
  678.                         Speak("You are carrying too much.");
  679.                     }
  680.                     else {
  681.                         Output("I've too much to carry.\n");
  682.                         Speak("I've too much to carry.");
  683.                     }
  684.                     return(0);
  685.                 }
  686.                 i=MatchUpItem(NounText,MyLoc);
  687.                 if(i==-1)
  688.                 {
  689.                     if(Options&YOUARE) {
  690.                         Output("It is beyond your power to do that.\n");
  691.                         Speak("It is beyond your power to do that.");
  692.                     }
  693.                     else {
  694.                         Output("It's beyond my power to do that.\n");
  695.                         Speak("It's beyond my power to do that.");
  696.                     }
  697.                     return(0);
  698.                 }
  699.                 Items[i].Location= CARRIED;
  700.                 Output("O.K.\n");
  701.                 Speak("O.K.");
  702.                 Redraw=1;
  703.                 return(0);
  704.             }
  705.             if(vb==18)
  706.             {
  707.                 if(stricmp(NounText,"ALL")==0)
  708.                 {
  709.                     int ct=0;
  710.                     int f=0;
  711.                     while(ct<=GameHeader.NumItems)
  712.                     {
  713.                         if(Items[ct].Location==CARRIED && Items[ct].AutoGet && Items[ct].AutoGet[0]!='*')
  714.                         {
  715.                             no=WhichWord(Items[ct].AutoGet,Nouns);
  716.                             disable_sysfunc=1;
  717.                             PerformActions(vb,no);
  718.                             disable_sysfunc=0;
  719.                             Items[ct].Location=MyLoc;
  720.                             OutBuf(Items[ct].Text);
  721.                             Speak(Items[ct].Text);
  722.                             Output(": O.K.\n");
  723.                             Speak(" O.K.");
  724.                             Redraw=1;
  725.                             f=1;
  726.                         }
  727.                         ct++;
  728.                     }
  729.                     if(f==0) {
  730.                         Output("Nothing dropped.\n");
  731.                         Speak("Nothing dropped.");
  732.                     }
  733.                     return(0);
  734.                 }
  735.                 if(no==-1)
  736.                 {
  737.                     Output("What ?\n");
  738.                     Speak("What?");
  739.                     return(0);
  740.                 }
  741.                 i=MatchUpItem(NounText,CARRIED);
  742.                 if(i==-1)
  743.                 {
  744.                     if(Options&YOUARE) {
  745.                         Output("It's beyond your power to do that.\n");
  746.                         Speak("It's beyond your power to do that.");
  747.                     }
  748.                     else {
  749.                         Output("It's beyond my power to do that.\n");
  750.                         Speak("It's beyond my power to do that.");
  751.                     }
  752.                     return(0);
  753.                 }
  754.                 Items[i].Location=MyLoc;
  755.                 Output("O.K.\n");
  756.                 Speak("O.K.");
  757.                 Redraw=1;
  758.                 return(0);
  759.             }
  760.         }
  761.     }
  762.     return(fl);
  763. }
  764.  
  765. void main(int argc, char *argv[])
  766. {
  767.     //FILE *f;
  768.     int vb,no;
  769.     char prog_name[32];
  770.  
  771.     strcpy(prog_name,argv[0]);
  772.     while(argv[1])
  773.     {
  774.         if(*argv[1]!='-')
  775.             break;
  776.         switch(argv[1][1])
  777.         {
  778.             case 'y':
  779.                 Options|=YOUARE;
  780.                 break;
  781.             case 'i':
  782.                 Options&=~YOUARE;
  783.                 break;
  784.             case 'd':
  785.                 Options|=DEBUGGING;
  786.                 break;
  787.             case 's':
  788.                 Options|=SCOTTLIGHT;
  789.                 break;
  790.             case 't':
  791.                 Options|=TRS80_STYLE;
  792.                 break;
  793.             case 'p':
  794.                 Options|=PREHISTORIC_LAMP;
  795.                 break;
  796.             case 'h':
  797.             default:
  798.                 fprintf(stderr,"%s: [-h] [-y] [-s] [-i] [-t] [-d] [-p] <gamename> [savedgame].\n",
  799.                         argv[0]);
  800.                 exit(1);
  801.         }
  802.         if(argv[1][2]!=0) {
  803.             fprintf(stderr,"%s: option -%c does not take a parameter.\n",argv[0],argv[1][1]);
  804.             exit(1);
  805.         }
  806.         argv++;
  807.         argc--;
  808.     }
  809.  
  810.     //printf("%d, %s, %s, %s\n",argc,argv[0],argv[1],argv[2]);
  811.     if (argc == 0) {
  812.         WBSTART = TRUE;
  813.         WBMessage = (struct WBStartup *) argv;
  814.         Init(WBMessage->sm_ArgList->wa_Name,"","");
  815.     }
  816.     else Init(prog_name,((argc<2)?"":argv[1]),((argc<3)?"":argv[2]));
  817.  
  818.     srand(time(NULL));
  819.     Look();
  820.     while(1)
  821.     {
  822.         if(Redraw!=0)
  823.         {
  824.             Look();
  825.             Redraw=0;
  826.         }
  827.         PerformActions(0,0);
  828.         if(Redraw!=0)
  829.         {
  830.             Look();
  831.             Redraw=0;
  832.         }
  833.         GetInput(&vb,&no);
  834.         switch(PerformActions(vb,no))
  835.         {
  836.             case -1:
  837.                 Output("I don't understand your command.\n");
  838.                 Speak("I don't understand your command.");
  839.                 break;
  840.             case -2:
  841.                 Output("I can't do that yet.\n");
  842.                 Speak("I can't do that yet.");
  843.                 break;
  844.         }
  845.         /* Brian Howarth games seem to use -1 for forever */
  846.         if(Items[LIGHT_SOURCE].Location/*==-1*/!=DESTROYED && GameHeader.LightTime!= -1)
  847.         {
  848.             GameHeader.LightTime--;
  849.             if(GameHeader.LightTime<1)
  850.             {
  851.                 BitFlags|=(1L<<LIGHTOUTBIT);
  852.                 if(Items[LIGHT_SOURCE].Location==CARRIED ||
  853.                     Items[LIGHT_SOURCE].Location==MyLoc)
  854.                 {
  855.                     if(Options&SCOTTLIGHT) {
  856.                         Output("Light has run out! ");
  857.                         Speak("Light has run out!");
  858.                     }
  859.                     else {
  860.                         Output("Your light has run out. ");
  861.                         Speak("Your light has run out.");
  862.                     }
  863.                 }
  864.                 if(Options&PREHISTORIC_LAMP)
  865.                     Items[LIGHT_SOURCE].Location=DESTROYED;
  866.             }
  867.             else if(GameHeader.LightTime<25)
  868.             {
  869.                 if(Items[LIGHT_SOURCE].Location==CARRIED ||
  870.                     Items[LIGHT_SOURCE].Location==MyLoc)
  871.                 {
  872.  
  873.                     if(Options&SCOTTLIGHT)
  874.                     {
  875.                         Output("Light runs out in ");
  876.                         Speak("Light runs out in ");
  877.                         OutputNumber(GameHeader.LightTime);
  878.                         SpeakNum(GameHeader.LightTime);
  879.                         Output(" turns. ");
  880.                         Speak(" turns.");
  881.                     }
  882.                     else
  883.                     {
  884.                         if(GameHeader.LightTime%5==0) {
  885.                             Output("Your light is growing dim. ");
  886.                             Speak("Your light is growing dim.");
  887.                         }
  888.                     }
  889.                 }
  890.             }
  891.         }
  892.     }
  893. }
  894.  
  895.